﻿using System.IO;

namespace OpenXml.Internal.IO.Packaging
{
    internal class TrackingMemoryStreamFactory : ITrackingMemoryStreamFactory
    {
        private long _bufferedMemoryConsumption;

        public MemoryStream Create()
        {
            return new TrackingMemoryStream(this);
        }

        public MemoryStream Create(int capacity)
        {
            return new TrackingMemoryStream(this, capacity);
        }

        public void ReportMemoryUsageDelta(int delta)
        {
            this._bufferedMemoryConsumption += delta;
        }

        internal long CurrentMemoryConsumption
        {
            get
            {
                return this._bufferedMemoryConsumption;
            }
        }
    }
}


